﻿#ifndef TCPCODEC_H
#define TCPCODEC_H

#include <qobject.h>
#include "ObjAutoInject.h"
#include "TcpCodecBase.h"
#include <qtimer.h>
#include <qhash.h>

class TcpIOer;
class RegisterCenter_User;
class UserRegisterCodec;
class TcpCodec :  public QObject,public ObjAutoInject,public TcpCodecBase
{
  Q_OBJECT
private://property
  QHash<unsigned char/*dataType*/,TcpCodecBase*> codecMap;
private://dependency
  RegisterCenter_User* registerCenter_User=Q_NULLPTR;
  UserRegisterCodec* userRegisterCodec=Q_NULLPTR;
public:
  explicit TcpCodec();
  virtual ~TcpCodec();
public:
  void code(DataPackage_TcpCodec* dataPackageInfo_User);
  void code(uint userId,uchar type,QByteArray data);
  virtual DataPackage_TcpCodec* decode(DataPackage_TcpCodec* dataPackageInfo_User)override;
public slots:
  void slot_decode(TcpIOer* const tcpIOer,QByteArray data);
signals:
public://geter and seter
  RegisterCenter_User* getRegisterCenter_User()const;
  TcpCodec* setRegisterCenter_User(RegisterCenter_User* const registerCenter_User);
  UserRegisterCodec* getUserRegisterCodec()const;
  TcpCodec* setUserRegisterCodec(UserRegisterCodec* const userRegisterCodec);
public:
  virtual void objectAutoInjection(QHash<QString,QObject*>* objMap)override;
};

#endif // TCPCODEC_H
